package me.zk.practice1.s;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * @author zhangkai
 * @date 2023/7/13 11:19
 */
public class LS_Offer_06 {
    public int[] reversePrint(ListNode head) {
        LinkedList<Integer> list = new LinkedList<>();
        while (head!= null) {
            list.add(head.val);
            head = head.next;
        }
        int[] result = new int[list.size()];
        int i = 0;
        while (!list.isEmpty()) {
            result[i] = list.removeLast();
            i++;
        }
        return result;
    }
}
